Ext.define('YXMES.sbas.controller.ViewMatInfoController', {
	extend : 'Ext.app.Controller',
	refs : [ {
		selector : 'sbas_viewmatinfo',
		ref : 'sbasviewmatinfo'
	} ],
	requires : [  ],
	stores : [],
	models : [],
	views : [ 'YXMES.sbas.view.ViewMatInfoView' ],
	subcontrollers : [  ],
	_init : false,
	init : function() {
		if (this._init)
			return;
		this._init = true;
		this.control({
			'sbas_viewmatinfo' : {
				afterrender : function() {
					return this.handle(this.onAfterrender, arguments);
				},
				destroy : function() {
					return this.handle(this.onDestroy, arguments);
				}
			}
		});
		if (!Ext.isEmpty(this.subcontrollers)) {
			Ext.each(this.subcontrollers, function(name) {
				this.getController(name).init();
			}, this);
		}
		// User definied init
	},
	mainView : undefined,
	getMainView : function() {
		return this.mainView;
	},
	getScopeView : function() {
		return this.getMainView().scopeView || {};
	},
	getInput : function() {
		return this.getScopeView().input || {};
	},
	setInput : function(data) {
		this.getMainView().input = data;
	},
	getOutput : function() {
		return this.getMainView().output || {};
	},
	setOutput : function(data) {
		this.getScopeView().output = data;
	},
	handle : function(func, args) {
		var item = args && args.length > 0 && Ext.typeOf(args[0]) === 'object' ? args[0] : undefined;
		if (item) {
			try {
				this.mainView = (item.xtype == 'sbas_viewmatinfo' ? item : item.up('sbas_viewmatinfo'));
			} catch(e) {
			}
		}
		try {
			return func.apply(this, args);
		} finally {
		}
	},
	getItem : function(itemId) {
		return this.getMainView().down('#' + itemId);
	},
	getStore : function(name) {
		return undefined;
	},
	bind : function(view) {
		view = (view ? view : this.getMainView());
	},
	onAfterrender : function(container, eOpts) {
		this.bind();
		// User defined afterrender
	},
	onDestroy : function(container, eOpts) {
		// User defined destory
		var view = this.getMainView();
		if (this.getMainView().input)
			this.getMainView().input = undefined;
		if (this.getMainView().output)
			this.getMainView().output = undefined;
	}
});